package com.cq.xjms.web.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class BaseAction extends ActionSupport{
	private static final long serialVersionUID = -148979817526297628L;
	public void write(String string) {
		try {
			getResponse().setCharacterEncoding("utf-8");
			getResponse().getWriter().write(string);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	public void writeJSON(String string) {
		try {
			getResponse().setCharacterEncoding("utf-8");
			getResponse().setContentType("application/json;charset=UTF-8");
			getResponse().getWriter().write(string);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	/**
	 * 获取Request对象
	 */
	protected HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}

	/**
	 * 获取Response对象
	 */
	protected HttpServletResponse getResponse() {
		System.out.print("sss");
		return ServletActionContext.getResponse();
	}

	/**
	 * 获取Session对象
	 */
	protected HttpSession getSession() {
		return getRequest().getSession();
	}

	
}
